#ifndef LOGIN_WIDGET_H
#define LOGIN_WIDGET_H

#include <QWidget>
#include <QSqlDatabase>

namespace Ui {
class LoginWidget;
}

class PanelMainWindow;  //< 主窗口前置声明
class DealerHandler; //< 网络管理器前置声明

class LoginWidget : public QWidget
{
    Q_OBJECT

public:
    explicit LoginWidget(QWidget *parent = nullptr);
    ~LoginWidget();

protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    bool eventFilter(QObject *obj, QEvent *event) override;

private slots:
    void onLoginButtonClicked();
    void onConfigButtonClicked();
    void onSaveButtonClicked();
    void onNetworkMessageReceived(const QString &method, const QString &body, bool is_error = false);
    void onShowPasswordButtonClicked();

private:
    /**
     * 初始化网络
     */
    void initNetwork();

    Ui::LoginWidget *ui_;
    bool is_dragging_;
    QPoint drag_position_;
    PanelMainWindow *main_window_;  // 主窗口指针
    DealerHandler *dealer_handler_; // 网络管理器指针
};

#endif // LOGIN_WIDGET_H
